package com.baway.biliclitent.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.baway.biliclitent.R;
import com.baway.biliclitent.model.RegionBean;
import com.bumptech.glide.Glide;

import java.util.List;

/**
 * Created by dell on 2017/3/10.
 */

public class RegionListBottomAdapter extends BaseAdapter{
    private Context context;
    List<RegionBean.DataBeanHeadline.NewBeanHeadline> newX;

    public RegionListBottomAdapter(Context context, List<RegionBean.DataBeanHeadline.NewBeanHeadline> newX) {
        this.context = context;
        this.newX = newX;
    }

    @Override
    public int getCount() {
        return newX.size();
    }

    @Override
    public Object getItem(int position) {
        return newX.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder v = null;
        if(convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.region_recomm_lv,null);
            v = new ViewHolder();
            v.item_img = (ImageView) convertView.findViewById(R.id.item_img);
            v.item_title = (TextView) convertView.findViewById(R.id.item_title);
            v.item_user_name = (TextView) convertView.findViewById(R.id.item_user_name);
            v.item_play = (TextView) convertView.findViewById(R.id.item_play);
            v.item_review = (TextView) convertView.findViewById(R.id.item_review);
            convertView.setTag(v);
        }else{
            v = (ViewHolder) convertView.getTag();
        }
        Glide.with(context).load(newX.get(position).getCover()).into(v.item_img);
        v.item_title.setText(newX.get(position).getTitle());
        v.item_user_name.setText(newX.get(position).getName());
        v.item_play.setText(newX.get(position).getPlay()+"");
        v.item_review.setText(newX.get(position).getDanmaku()+"");
        return convertView;
    }
    class ViewHolder{
        ImageView item_img;
        TextView item_title,item_user_name,item_play,item_review;
    }
}
